#include<iostream>
#include<cmath>
using namespace std;

class point
{
    friend class point2;
    private:
        int x,y;
    public:
        point(int a,int b)
        {
            x=a;
            y=b;
        }
        int getx()
        {
            return x;
        }
        int gety()
        {
            return y;
        }
        friend float dist(point &aa,point &bb);
};
float dist(point &aa,point &bb)
{
    double x = aa.x-bb.x;
    double y = aa.y-bb.y;
    return sqrt(x*x+y*y);
}


class point2
{
point p;
public:
    point2(int m,int n);
    ~point2();
    void set(int i, int j);
    void display();
};

point2::point2(int m,int n):p(m,n)
{
    cout<<"Constructor called"<<endl;
}

point2::~point2()
{
    cout << "destroy point2" << endl;
}

void point2::set(int i,int j)
{
    p.x=i;
    p.y=j;
}
void point2::display()
{
    cout<<"("<<p.x<<","<<p.y<<")"<<endl;
}

int main(){
    point p1(1,2);
    point p2(3,4);
    cout<<"distance between p1 and p2 is "<<dist(p1,p2)<<endl;
    point2 p3(5,6);
    p3.set(7,8);
    p3.display();
    return 0;
}


